package com.yf.dxs.wo.redis;

import com.yf.dxs.utils.JsonUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.RedisTemplate;

@AllArgsConstructor
public class RedisMqTemplate {

    @Getter
    private final RedisTemplate<String, ?> redisTemplate;



    public void sendMsg(AbstractRedisMsg redisMsg){
        redisTemplate.opsForStream().add(StreamRecords.newRecord().ofObject(JsonUtils.toJsonString(redisMsg)).withStreamKey(redisMsg.getStreamKey()));
    }

}
